package cn.stu.framework.service.impl;


import cn.stu.common.core.Constants;
import cn.stu.common.utils.R;
import cn.stu.framework.entity.SysListener;
import cn.stu.framework.mapper.SysListenerMapper;
import cn.stu.framework.service.ISysListenerService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * 流程监听Service业务层处理
 *
 * @author Tony
 * @date 2022-12-25
 */
@Service
@AllArgsConstructor
public class SysListenerServiceImpl implements ISysListenerService {
    private SysListenerMapper sysListenerMapper;

    /**
     * 查询流程监听
     *
     * @param id 流程监听主键
     * @return 流程监听
     */
    @Override
    public R selectSysListenerById(Long id) {
        SysListener sysListener = sysListenerMapper.selectSysListenerById(id);
        return R.ok(sysListener, "获取成功");
    }

    /**
     * 查询流程监听列表
     *
     * @param sysListener 流程监听
     * @return 流程监听
     */
    @Override
    public R selectSysListenerList(SysListener sysListener) {
        List<SysListener> sysListeners = sysListenerMapper.selectSysListenerList(sysListener);
        return R.ok(sysListeners, "获取成功");
    }

    /**
     * 新增流程监听
     *
     * @param sysListener 流程监听
     * @return 结果
     */
    @Override
    public R insertSysListener(SysListener sysListener) {
        sysListenerMapper.insert(sysListener);
        return R.ok(Constants.OPERATION_SUCCESS);
    }

    /**
     * 修改流程监听
     *
     * @param sysListener 流程监听
     * @return 结果
     */
    @Override
    public R updateSysListener(SysListener sysListener) {
        sysListenerMapper.updateById(sysListener);
        return R.ok(Constants.OPERATION_SUCCESS);
    }

    /**
     * 批量删除流程监听
     *
     * @param ids 需要删除的流程监听主键
     * @return 结果
     */
    @Override
    @Transactional
    public R deleteSysListenerByIds(Long[] ids) {
        sysListenerMapper.deleteSysListenerByIds(ids);
        return R.ok("删除成功");
    }

    /**
     * 删除流程监听信息
     *
     * @param id 流程监听主键
     * @return 结果
     */
    @Override
    public R deleteSysListenerById(Long id) {
        sysListenerMapper.deleteById(id);
        return R.ok("删除成功");
    }
}
